const { ccclass, property } = cc._decorator;

enum playModel {
    easy = 0,
    difficult = 1,
    arduous = 2
}

@ccclass
export default class ChoiceMX extends cc.Component {
    @property(cc.Node)
    checked: cc.Node = null;
    @property(cc.Node)
    easyBt: cc.Node = null;
    @property(cc.Node)
    difficultBt: cc.Node = null;
    @property(cc.Node)
    arduousBt: cc.Node = null;

    selectEvents: Array<cc.Component.EventHandler> = [];
    _playModel: playModel = playModel.easy;
    onLoad() {
        this.easy();
    }
    // update (dt) {}

    //容易
    easy() {
        this.setCheck(playModel.easy);
        this.showCheck(this.easyBt.y);
    }
    //挑战
    arduous() {
        this.setCheck(playModel.arduous);
        this.showCheck(this.arduousBt.y);
    }
    //困难
    difficult() {
        this.setCheck(playModel.difficult);
        this.showCheck(this.difficultBt.y);
    }
    showCheck(nodeY: number) {
        this.checked.active = true;
        this.checked.y = nodeY;
    }
    setCheck(model: playModel) {
        this._playModel = model;
        cc.Component.EventHandler.emitEvents(this.selectEvents, {
            target: this,
            index: this._playModel
        });
    }
}
